Audio Device Contention Manager

  Contents

Background

What is "Audio Device Contention"?

On some Windows systems, limitations in the installed sound hardware, the software drivers for the sound hardware, or the operating system's audio architecture may result in a situation where the Beatnik Player cannot play audio at the same time as other media players that wish to play audio. Typically, with these systems only one application can use the system's audio services at a time. This limitation may often result in a situation where two (or more) applications are contending for this single audio device that cannot be shared by multiple applications simultaneously. This problematic situation is referred to as an "audio device contention".

How Beatnik Content is Affected

On systems that are not able to share the audio device from multiple applications simultaneously, content sonified using the Beatnik Player could be affected primarily in two ways...

Not a Widespread Problem

The audio device contention issue is not a widespread problem. A small percentage of Windows systems are affected - mostly systems with older versions of the Windows operating system (such as Windows 95 and earlier versions of Windows NT) and older audio hardware. By far the majority of new Windows systems have the appropriate combination of audio hardware, software drivers, and operating system in order to allow multiple applications to mix audio simultaneously. There may be a very small number of new systems that still have this limitation, but the chances are quite low.

Even though the number of users experiencing this problem may be low, it is - nevertheless - not an insignificant problem. And if it results in a developer choosing not to use the Beatnik technology in their Web content because they have no way of managing this problem, this could potentially be very damaging to the adoption of the Beatnik technology in general.

Enter the "Audio Device Contention Manager"

With the Beatnik Player version 2.1, a system was put in place to manage this problem and help to avoid situations where the use of the Beatnik Player in sonifying a Web site could interfere with some users' ability to experience audio or audiovisual content through other media players - situations which could otherwise lead to technical support queries for the manager or developer of the Web site and which could potentially damage the reputation of the site.

This system is aptly named the "Audio Device Contention Manager" and is referred to throughout the remainder of this document simply as the ADCM.

The System Explained

Goals of the System

The primary goal behind the design of the ADCM system is to provide as easy a way as possible for content authors to avoid exposing users to the audio device contention issue, with minimal modification of content needed in most cases in order to gain the benefits of the system.

Secondary goals include...

The System's Approach to the Problem

Because it is beyond Beatnik's power to rewrite inadequate older operating systems or magically manifest new audio hardware for those systems that are mixing-challenged, the ADCM focuses on measures designed to alleviate the problem and to drastically reduce the incidence of situations where the user is trying to use a media player but cannot hear audio as expected.

Feedback received from developers of high traffic Web sites indicates that while broad sonification of a Web site is an enhancement that these developers are willing to invest their effort in, such sonification is not compelling enough to take priority over the many other media offerings that these Web sites make available that are targeted for playback through other media players (such as RealNetworks' RealPlayer, Microsoft's Media Player, Apple's QuickTime Player, etc.).

When faced with a choice between having broad Web site sonification, that may cause audio device contention problems for a small yet not insignificant percentage of their users, and having no Web site sonification with the guarantee that no additional tech support problems will be introduced as a result of using the Beatnik technology, such Web developers would choose to forgo the Beatnik sonification. The risk of incurring tech support problems is just too great of a concern.

These same developers, however, have no problem with having other dedicated Beatnik audio applications, such as eMixes, launched from certain pages of their Web site. Because an eMix is a dedicated audio application that has a "face" and is associated, in the user's mind, with a specific "player" window, the user's expectations are different. For example, a user who has a system with the potential for audio device contention situations may have already experienced the inability to hear Real Audio content while playing streaming audio in another window through the QuickTime player. A dedicated Beatnik audio application is much the same, in this regard, and such a user will probably understand that an eMix needs to be closed first before opening a link to Real Audio content, and vice versa.

Developers who have sonified high traffic Web sites do see the value to adding a tasteful "soundtrack" to a Web site, and they would like to be able to offer this added richness in their content. They just don't want to incur the wrath of a small percentage of their users in doing so. In fact, being able to easily disable sonification for just those users who's systems are not capable of mixing audio from multiple applications is quite an attractive solution to these developers, since the majority of users who do not have such problems with their systems can still get the full experience intended by the developer.

The ADCM system, that is incorporated into Beatnik Player versions 2.1 and higher, combines the concept of audio device priority with an improved behavior for the Music.engageAudio static method to make it possible to use Beatnik in sonifying a high traffic Web site, and have the sonification automatically yield on those systems that cannot mix audio from multiple applications.

The Concept of Audio Device Priority

The concept of "audio device priority" was introduced as a means for sonified content to indicate how "hungry" it is to use the system's audio device when the system is incapable of sharing the audio device with other applications simultaneously (ie. mixing audio from multiple applications). In simple terms, the lowest audio device priority level indicates that the content thoroughly desires to not be using the audio device on problematic systems, whereas the highest audio device priority level indicates that the content is completely unwilling to let go of the audio device on such systems.

A sonified document may be set to one of four possible audio device priority levels...

Logical Defaults

Because of the sensible default of audio device priority level 1, no action will be required for most sonified content in order to gain the benefits of the ADCM system. There are really just a few types of content where explicitly setting an audio device priority level is desirable. And, even in such cases where audio device priority level needs to be set explicitly, the ADCM makes it a snap.

Using the System is Simple

The ADCM has been designed in such a way that the burden is not placed on you, as a content developer, to determine if the user's system has the potential for audio device contention. In fact, all that you need to do is to choose an audio device priority level appropriate for your sonified content, to achieve the desired ADCM behavior for that content on problematic systems. For systems that are fully capable of mixing audio from multiple applications, the audio device priority setting simply has no effect. So, nothing needs to be specially conditionalized for these different systems.

The following rather straightforward sample code example illustrates the code that would need to be added in a typical application of the ADCM...

<HTML><HEAD><TITLE>High Traffic Site - Navbar</TITLE></HEAD>
<BODY>

<SCRIPT SRC="music-object.js"></SCRIPT>

<SCRIPT LANGUAGE=JavaScript><!-- //

Music.setAudioDevicePriority (0);

uiPlayer = new Music ();
jinglePlayer = new Music ();
backgroundPlayer = new Music ();

uiPlayer.stubEmbed ('music/stub.rmf');
jinglePlayer.preloadEmbed ('music/corporate-jingle.rmf');
backgroundPlayer.magicEmbed (
   'SRC="music/bg-theme.rmf" ' +
   'HIDDEN WIDTH=0 HEIGHT=0 ' + 
   'AUTOSTART=TRUE LOOP=TRUE'
);

// --></SCRIPT>

<!--......................rest of document follows......................-->

In the above sample code listing, the highlighted code indicates the code that has been added in order to customize the ADCM's behavior. Notice how it is only one line of code.

In this example, the sonified document represents a navigation bar that will be loaded into one frame of the Web site's frameset and will persist throughout the site. Because the site may contain documents that use other media players (such as Macromedia's Flash Player, Apple's QuickTime Player, etc.), we need to ensure that the Beatnik Player is not using the system's audio device when the window containing this site is focused (ie. the user is browsing it) and the user's system is not capable of mixing audio from multiple applications. In order to ensure this, all that is needed is to set the audio device priority level for the sonified document to 0. This is done quite simply by calling the Music.setAudioDevicePriority static method immediately after sourcing in the "music-object.js" file.

While this example addresses only one type of situation, most other situations can be addressed just as easily by selecting appropriate audio device priority levels for sonified documents. More sophisticated management of the audio device contention issue can be achieved, if desired, using the various other API features of the ADCM (see the section API Features for Customizing the Behavior of the ADCM).

When the Engine's Audio Engaged State is Re-assessed

The audio engaged state for the audio engine is typically re-assessed each time one of the following events occurs...

Rules Used to Determine Audio Engaged State

Each time that the engaged state for the audio engine is re-assessed (see the section When the Engine's Audio Engaged State is Re-assessed), the following rules are used to determine the audio engine's new engaged state...

Upon first inspection, this may seem like some fairly tricky logic, but it is this set of rules that achieves the desired and intuitive behaviors for the various audio device priority levels 0, 1, 2, and 3, as well as the improved behavior for the Music.engageAudio static method (see the section New Behavior for the Music.engageAudio Method).

What Happens When the Audio Engaged State Changes

Each time there is a change in the engaged state of the audio engine, the onAudioEngagedChange static callback will be triggered. At this time, any handlers that have been registered for this callback (using the dedicated Music.onAudioEngagedChange static method or the more general Music.addCallbackHandler static method) will be executed.

By registering handlers for the onAudioEngagedChange static callback, the engaged state of the audio engine can be reflected in a sonified document's user interface or the user can be alerted. This can help to avoid situations where the user has the expectation of hearing audio from Beatnik-sonified content when, in actual fact, the Beatnik Player is not able to play audio at that moment because some condition has caused the audio engine to become disengaged.

While the onAudioEngagedChange callback is used to monitor changes that occur in the player's global audio engine that is shared by all sonified documents, multiple sonified documents can independently register handlers for this callback. All handlers registered for this callback by all sonified documents will be executed each time there is a change in the audio engine's engaged state, so all sonified documents have the option of indicating this state in some manner in their user interface, or otherwise acting on updates of the audio engine's engaged state.

API Features for Customizing the Behavior of the ADCM

Several new static methods were introduced in Music Object 3.3 to allow the behavior of the ADCM system to be customized to suit the needs of specific sonified content. These new static methods are as follows...

Alleviating Audio Device Contentions with Player Versions Earlier than 2.1

With player versions earlier than 2.1, it is still possible to alleviate the audio device contention problem in a limited manner by using the Auto Disengage extension. And, without any extra work, this extension can also provide improved behavior under the ADCM system that is incorporated into Beatnik Player versions 2.1 and higher.

Examples

Example 1: A Mixed Media Web Site (Audio Device Priority 0)

Audio Device Contention Manager - Example 1

Example 2: A Dedicated Music Application (Audio Device Priority 2)

Audio Device Contention Manager - Example 2

Example 3: A Mixed Media Web Site with a Dedicated Beatnik Music Application

Audio Device Contention Manager - Example 3

Example 4: A non-Beatnik Dedicated Music Application

Audio Device Contention Manager - Example 4

Backwards Compatibility Issues

Music Object 3.3 (or higher), Player Earlier Than 2.1

The API for the ADCM has been designed deliberately in such a way as to fail gracefully when the player installed in the user's browser is earlier than version 2.1.

In most cases, content authors who have concerns about the audio device contention issue will merely update their content to include a call to the Music.setAudioDevicePriority static method before any player instances have been embedded. This method, as it is implemented in the Music Object API, is designed to fail gracefully with Beatnik Player versions earlier than 2.1.

While the value returned by the Music.getAudioDevicePriority static method will correctly return the last value that was set using the Music.setAudioDevicePriority static method, Beatnik Player versions earlier than 2.1 will simply not exhibit any of the behaviors of the ADCM system because these versions of the player do not incorporate this system.

In some more sophisticated cases, content authors may make use of the other API features of the ADCM, such as the Music.isAudioEngaged, Music.isAudioDeviceShared, and Music.onAudioEngagedChange static methods. These methods have all been designed so as to fail gracefully when the installed version of the Beatnik Player is earlier than 2.1.

New Behavior for the Music.engageAudio Method

History

The Music Object API's Music.engageAudio static method and the obsoleted engageAudio instance method have been used historically to try to manage the audio device contention issue. However, because of security restrictions that are placed upon the JavaScript language, different sonified windows are not able to cooperate with one another in setting the engaged state of the player's underlying audio engine. Consequently, with the behavior of the Music.engageAudio method in Beatnik Player versions earlier than 2.1, different sonified windows could potentially "step all over" one another in trying to engage or disengage the audio engine.

Cooperative vs. Explicit

The new behavior for the Music.engageAudio static method, introduced at Beatnik Player version 2.1, prevents this kind of tug of war situation. With the new behavior, a sonified document uses the Music.engageAudio method to register whether or not it wishes the audio engine to be engaged, based upon its understanding of whether or not there is any audio activity in the document. Using the Music.engageAudio method no longer has the effect of explicitly setting the engaged state of the audio engine. Instead, the audio device priority settings for all sonified documents, along with all calls that have been made to the Music.engageAudio method by the sonified documents, and the focused states of the various windows containing the sonified documents are used to cooperatively determine the audio engine's engaged state.

For a better understanding of the rules that are used to determine the audio engine's engaged state, consult the section The System Explained: Rules Used to Determine Audio Engaged State.

Emulating Audio Device Contention

Working in the Dark

While there are a good number of Windows systems that may be prone to the audio device contention issue, there is no guarantee that a Windows system that you are doing development or testing on will actually exhibit this problem. If your Windows system does not exhibit the problem, then the Beatnik Player will not, by default, engage the ADCM in order to mitigate the problem. Any customizations that you make to the ADCM's behaviors will not affect the behavior of your content on such a system, and so you will not be able to gauge how these settings would affect the user experience for a user who's system does exhibit the audio device contention issue. So, you would essentially be working in the dark.

Registry Scripts for Player 2.2 and Higher

In order to help you in customizing your sonified content to best make use of the ADCM, Beatnik Player versions 2.2 and higher (Windows only) allow you to coerce the player into thinking that the system either does or does not exhibit the audio device contention issue (regardless of whether it truly does or not). This effectively overrides the player's auto-detection for audio device contention.

Coercing the different behaviors is achieved quite easily through the use of the convenient registry scripts that are provided along with this documentation. These scripts are listed and described in the table below...

Script Filename Description
force-contention-behavior.reg

Forces the Beatnik Player to act as though the system exhibits the audio device contention issue (regardless of whether it truly does or not). In this mode, the player's auto-detection is overridden and the ADCM is always engaged.

NOTE  Forcing the ADCM to be engaged has no effect on a system where the ADCM would have been engaged, anyway.

force-no-contention-behavior.reg

Forces the Beatnik Player to act as though the system does not exhibit the audio device contention issue (regardless of whether it truly does or not). In this mode, the player's auto-detection is overridden and the ADCM is never engaged.

NOTE  Forcing the ADCM to not be engaged has no effect on a system where the ADCM would not have been engaged, anyway. On the other hand, forcing the ADCM to not be engaged on a system that does exhibit the audio device contention issue is a useful way of seeing the beneficial impact of the ADCM on the user experience for such systems.

restore-default-behavior.reg Restores the Beatnik Player to normal ADCM operation mode. In this mode, the player automatically determines whether or not the system exhibits the audio device contention issue and only engages the ADCM if the system does exhibit the issue.

In order to run one of these registry scripts, save the desired script to your desktop. To do this, simply right-click on the script's filename in the above table. Then, from the menu that pops up, select the 'Save Link As...' or 'Save Target As...' option and save the file to your desktop. Once the file is saved, locate the file on your desktop and double-click on it in order to run it. Once the script has been run, the appropriate registry entry for the Beatnik Player will have been updated. In order for the change to take effect in the Beatnik Player, you should quit and relaunch your browser.

NOTES
Further Scenarios

The following diagrams illustrate different combinations of ADCM settings for different windows, and how the states of these windows ultimately determines whether or not the audio engine is engaged (as indicated by the return value of the Music.isAudioEngaged static method shown underneath each diagram). It should be stressed that these illustrations indicate the expected results for problematic systems and that, for systems that are fully capable of mixing audio from multiple applications simultaneously, it should be expected that the Music.isAudioEngaged method would always return the value true.

Diagram 1a

Audio Device Contention Manager - Diagram 1a

Diagram 1b

Audio Device Contention Manager - Diagram 1b

Diagram 1c

Audio Device Contention Manager - Diagram 1c

Diagram 1d

Audio Device Contention Manager - Diagram 1d

Diagram 2a

Audio Device Contention Manager - Diagram 2a

Diagram 2b

Audio Device Contention Manager - Diagram 2b

Diagram 2c

Audio Device Contention Manager - Diagram 2c

Diagram 2d

Audio Device Contention Manager - Diagram 2d

Diagram 3a

Audio Device Contention Manager - Diagram 3a

Diagram 3b

Audio Device Contention Manager - Diagram 3b

Diagram 3c

Audio Device Contention Manager - Diagram 3c

Diagram 3d

Audio Device Contention Manager - Diagram 3d

Diagram 3e

Audio Device Contention Manager - Diagram 3e

Diagram 3f

Audio Device Contention Manager - Diagram 3f

Diagram 3g

Audio Device Contention Manager - Diagram 3g